﻿using System;
using AutoMapper;
using System.ComponentModel.DataAnnotations;
using PmSoft;
using static Modules.Person.PersonConstants;
using static Modules.Project.ProjectConstants;

namespace ManagementApi.Models.Payroll;

/// <summary>
/// 工资单设置
///</summary>
public class WagePayrollSettingEditForm
{
    /// <summary>
    /// 主键
    ///</summary>
    [Display(Name = "主键")]
    public int? Id { get; set; }

    /// <summary>
    /// 行业分类
    ///</summary>
    [Display(Name = "行业分类")]
    public 行业主管部门? IndustryType { get; set; }

    /// <summary>
    /// 工种
    ///</summary>
    [Display(Name = "工种")]
    public 工人工种? WorkType { get; set; }

    /// <summary>
    /// 按月发放，每人每月限额
    ///</summary>
    [Display(Name = "按月发放，每人每月限额")]
    [Required(ErrorMessage = "{0}不能为空")]
    public decimal? MonthlyLimit { get; set; }

    /// <summary>
    /// 按日发放，每人每日限额
    ///</summary>
    [Display(Name = "按日发放，每人每日限额")]
    [Required(ErrorMessage = "{0}不能为空")]
    public decimal? DailyLimit { get; set; }

    #region 扩展字段

    //这里自行增加扩展字段，如 项目名称

    #endregion 扩展字段
}

public static class WagePayrollSettingExtensions
{
    public static WagePayrollSettingEditForm AsForm(this Modules.WagePayrollSetting entity)
    {
        WagePayrollSettingEditForm form = new();
        var mapper = ServiceAccessor.GetService<IMapper>();
        mapper.Map(entity, form);

        return form;
    }
}